Skip to content

[REFACTOR][IR][FFI] Bump tvm-ffi (+ SEqHashDef migration) and phase out tvm/ir/repr.h#19627

Merged
spectrometerHBH merged 2 commits into
apache:mainfrom
tqchen:tvm-bump-ffi-and-phase-out-repr-h
May 27, 2026
Merged

[REFACTOR][IR][FFI] Bump tvm-ffi (+ SEqHashDef migration) and phase out tvm/ir/repr.h#19627
spectrometerHBH merged 2 commits into
apache:mainfrom
tqchen:tvm-bump-ffi-and-phase-out-repr-h

Conversation

@tqchen
Copy link
Copy Markdown
Member

@tqchen tqchen commented May 27, 2026

Summary

Two-commit PR:

  1. Bump 3rdparty/tvm-ffi from 3c35034 to 98d0029 and migrate all 21 in-tree SEqHashDef() call sites to SEqHashDefRecursive() (the conservative variant matching the prior default behavior). Six let-style sites carry TODO(tqchen) comments indicating they should flip to SEqHashDefNonRecursive after the new tvm-ffi ships on pypi.

  2. Phase out include/tvm/ir/repr.h. The bumped tvm-ffi now provides ostream operator<< for Any/ObjectRef/Variant/Optional directly in tvm/ffi/extra/dataclass.h, making the in-tree thin wrapper redundant. Rewrite 8 includers, rename src/ir/repr.ccsrc/ir/access_path_repr.cc (preserves node.AsRepr + AccessPath/AccessStep __ffi_repr__ registrations; drops zero-caller tvm::Dump()), delete the header. Also fixes a Python-level import regression in python/tvm/ir/attrs.py caused by the bump: tvm_ffi 0.1.12.dev changes the field-registration guard from not hasattr(cls, name) to name not in cls.__dict__, which breaks DictAttrs because DictAttrsNode registers a reflection field named "__dict__" — Python forbids installing a class descriptor with that name via setattr. Fix: define __dict__ as an explicit Python property on DictAttrs so the auto-installation is skipped.

TODO follow-ups

After the new tvm-ffi releases on pypi, flip the 6 SEqHashDefRecursive() sites that carry TODO(tqchen) comments to SEqHashDefNonRecursive(). Locations are enumerated in the commit body of commit 1.

Test plan

  • Full ninja build clean (638/638).
  • 118/118 cpptest pass.
  • import tvm; tvm.cuda(0).exist returns True.
  • tests/python/all-platform-minimal-test: 37 passed, 105 skipped.
  • tests/python/relax/test_struct_info.py: 9 passed.
  • git grep -nE 'SEqHashDef\(|"tvm/ir/repr\.h"' is empty.
  • pre-commit run --all-files clean.

tqchen added 2 commits May 27, 2026 17:24
Bump 3rdparty/tvm-ffi from 3c35034 to 98d0029 (13 commits). The bump
range brings in the new tvm/ffi/extra/dataclass.h ostream operator<<
overloads (PR apache#596) used by the follow-up repr.h phase-out commit,
plus the SEqHashDef -> SEqHashDef{Recursive,NonRecursive} rename
(PR apache#583).

All 21 in-tree SEqHashDef() call sites migrate to
SEqHashDefRecursive() — the conservative variant matching the prior
default behavior. Sites that are semantically let-style and should
eventually flip to SEqHashDefNonRecursive once the new tvm-ffi
releases on pypi carry a TODO(tqchen) comment:

  include/tvm/relax/expr.h:577     BindingNode::var
  include/tvm/relax/expr.h:619     MatchCastNode::struct_info
  include/tvm/tirx/buffer.h:129-135 BufferNode::data/shape/strides/elem_offset
  include/tvm/tirx/expr.h:701      LetNode::var
  include/tvm/tirx/stmt.h:89       BindNode::var
  include/tvm/tirx/stmt.h:276      AllocBufferNode::buffer
…class.h

The previous commit bumped tvm-ffi to a version that ships ostream
operator<< for Any / ObjectRef / Variant / Optional directly in
tvm/ffi/extra/dataclass.h, making the in-tree tvm/ir/repr.h thin
wrapper redundant.

- Delete include/tvm/ir/repr.h.
- Rewrite 8 includers: replace #include <tvm/ir/repr.h> with
  #include <tvm/ffi/extra/dataclass.h>, or just drop the include where
  dataclass.h was already pulled in transitively.
- Rename src/ir/repr.cc to src/ir/access_path_repr.cc. The file's only
  remaining role is the node.AsRepr FFI registration plus the
  __ffi_repr__ hooks for ffi::reflection::AccessPath / AccessStep.
  Drop the (unused, zero in-tree callers) tvm::Dump() bodies; gdb
  users can call tvm::ffi::ReprPrint directly.
- python/tvm/ir/attrs.py: add a Python-level __dict__ property on
  DictAttrs so that tvm_ffi's _add_class_attrs does not attempt to
  install a class descriptor named "__dict__" (Python forbids adding
  such a descriptor on extension-type subclasses via setattr). This
  fixes the import regression introduced by the bump to tvm_ffi
  0.1.12.dev (which changed the field-registration guard from
  "not hasattr(cls, name)" to "name not in cls.__dict__").
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the tvm-ffi subproject, removes the legacy tvm/ir/repr.h header and its associated tvm::Dump helper functions, and replaces them with tvm::ffi::ReprPrint. It also updates reflection registrations across various TVM IR nodes to use SEqHashDefRecursive instead of SEqHashDef, and adds a __dict__ property to DictAttrs in Python to avoid conflicts with C++ reflection registration. There are no review comments, and I have no additional feedback to provide.

@spectrometerHBH spectrometerHBH merged commit 2f4f4b1 into apache:main May 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants